package org.vectrics.common.view;

/**
 * @Author Mike Moore
 * @Version 1.0
 */
import org.apache.log4j.Category;

public class StandardTemplatePage extends StandardPage {
    private String content = "";
    private static Category log = Category.getInstance(StandardTemplatePage.class);

    public StandardTemplatePage() {
    }

    public void init() {
        log.debug("init() called.");
    }

    public void setContent(String content) {
        log.debug("setContent() called.");

        //Remove HTML tag in content.  ECS base class generates <HTML> tags surrounding content.
        int pos = content.toLowerCase().indexOf("<html>");
        if (pos >= 0) {
            StringBuffer fixedContent = new StringBuffer();

            int pos2 = content.toLowerCase().indexOf("</html>");
            if (pos > 0)
                fixedContent.append(content.substring(0, pos - 1));

            if (pos2 > 0) {
                fixedContent.append(content.substring(pos + 6, pos2 - 1 ));
            }
            else {
                fixedContent.append(content.substring(pos + 6));

            }

            addElement(fixedContent.toString());
        }
        else {
            addElement(content.toString());
        }
    }

}